﻿<?php 
defined('_JEXEC') or die('Accès interdit'); 
?>

	
	<link rel="stylesheet" type="text/css" href="components/com_tournoi/plugins/jquery_ui_multiselect/css/common.css">	
	<link rel="stylesheet" type="text/css" href="components/com_tournoi/plugins/jquery_ui/css/jquery-ui-1.8.21.custom.css" />
	<link rel="stylesheet" type="text/css" href="components/com_tournoi/plugins/jquery_ui_multiselect/css/ui.multiselect.css">


	<script src="components/com_tournoi/plugins/jquery/jquery-1.7.2.min.js"></script>
	<script src="components/com_tournoi/plugins/jquery_ui/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>
	<script src="components/com_tournoi/plugins/jquery/i18n/grid.locale-fr.js" type="text/javascript"></script>
	<script src="components/com_tournoi/plugins/jquery_ui_multiselect/ui.multiselect.js" type="text/javascript"></script>
	
	
	
<script>
$(function() {
	$( "#datedebut" ).datepicker();
	$( "#datedebut" ).datepicker( "option", "dateFormat", 'dd/mm/yy', {showOn: "button",buttonImage: "images/calendar.gif",	buttonImageOnly: true} );
	$( "#tabs" ).tabs();
	$('.numbersOnly').keyup(function () {this.value = this.value.replace(/[^0-9\.]/g,'')});
	$('.heureOnly').keyup(function () {this.value = this.value.replace(/[^0-9\:]/g,'')});
	$(".multiselect").css('width', '600px');		
    $(".multiselect").multiselect({sortable: false, searchable: true, dividerLocation: 0.5});
	$(".ui-multiselect").css('width', '680px');
	$(".selected").css('width', '340px');
	$(".available").css('width', '339px'); 

	jQuery("#grid_id").jqGrid(
			{
				datatype: "local",
				rowNum: 20,
				autowidth: false,
				width: 720,
				height: 250,
				rowList: [10, 100, 500],
				emptyrecords: "Aucun enregistrement à afficher",
				multiselect: false, 
				multiboxonly : true,
				colModel:
				[ 
					{ name: 'duree', index: 'duree', width: 189, label: 'Duree', sortable: false},
					{ name: 'smallBlind', index: 'smallBlind', width: 150, label: 'Small blind', sortable: false},
					{ name: 'bigBlind', index: 'bigBlind', width: 100, label: 'Big blind', sortable: false},
					{ name: 'ante', index: 'ante', width: 50, label: 'Ante', sortable: false},
					{ name: 'addon', index: 'addon', width: 100, label: 'Add on', sortable: false}
					{ name: 'recave', index: 'recave', width: 100, label: 'Recave', sortable: false}
					{ name: 'pause', index: 'pause', width: 100, label: 'Pause', sortable: false}
				], 	// Inititalise la liste des champs disponible et leur option d'affichage
				shrinkToFit :false, // Permet de ne pas dimensionner le tableau en fonction du contenu
				viewrecords: true, 
				sortable: false, // Permet le drag ans drop pour reorganiser les colonnes
				loadError : function(xhr, status, error)
				{
				alert("Erreur de chargement des données(" + status + "). Veuillez réessayer."); // Message d'erreur affiché en cas d'erreur de chargement du a un tmeout par exemple
				}
				});
					
				var i=1;
				<?php 
					foreach($this->contentsList as $dataContent) {
				?>
				var tournoi1 = new tournoi("<?php echo $dataContent->id;?>", 
					"<?php echo $dataContent->duree;?>", 
					"<?php echo $dataContent->smallBlind;?>", 
					"<?php echo $dataContent->bigBlind;?>", 
					"<?php echo $dataContent->ante;?>", 
					"<?php echo $dataContent->addon;?>", 				
					"<?php echo $dataContent->recave;?>", 				
					"<?php echo $dataContent->pause;?>" 
					);
					jQuery("#grid_id").jqGrid('addRowData',i+1,tournoi1);
					i++;
					<?php
						}
					?>
});
</script>			
	
<script type="text/javascript">	
	function changeRecave()
	{	
		if (document.getElementById('recave').selectedIndex == '1')
		{
			document.getElementById('jetonRecave').disabled=false;
			document.getElementById('montantRecave').disabled=false;
		}
		else
		{
			document.getElementById('jetonRecave').value="";
			document.getElementById('jetonRecave').disabled=true;
			document.getElementById('montantRecave').value="";
			document.getElementById('montantRecave').disabled=true;
		}			
		
	}

	function changeAddOn()
	{	
		if (document.getElementById('addOn').selectedIndex == '1')
		{
			document.getElementById('jetonAddon').disabled=false;
			document.getElementById('montantAddon').disabled=false;
		}
		else
		{
			document.getElementById('jetonAddon').value="";
			document.getElementById('jetonAddon').disabled=true;
			document.getElementById('montantAddon').value="";
			document.getElementById('montantAddon').disabled=true;			
		}			
	}
</script>	
			
<div class="component_simplethu">
	<h1 class="componentheading">Créer</h1>
	<form action="index.php?option=com_tournoi&task=creation" method="post">
		<div id="tabs">
			<ul>
				<li><a href="#tabs-1">Informations générales</a></li>
				<li><a href="#tabs-2">Informations tournois</a></li>
				<li><a href="#tabs-3">Structure</a></li>
				<li><a href="#tabs-4">Participants</a></li>
			</ul>
			<div id="tabs-1">
				<br>
				Titre :&nbsp;&nbsp;&nbsp;<input alt="Titre du tournoi" name="titre"
				 size="87">
				<br>
				<br>
				Lieu :&nbsp;&nbsp;&nbsp; <input alt="Lieu physique du tournoi"
				 name="lieu" size="87">
				<br>
				<br>
				Date :&nbsp;&nbsp; <input  alt="Date du tournoi" type="text" id="datedebut" name="datedebut" size="23">
				&nbsp;&nbsp; Heure :&nbsp;&nbsp;&nbsp; <input alt="Heure de d&eacute;but du tournoi" class="heureOnly" name="heuredebut" size="23">	
				<br>
				<br>
				Description :
				<textarea name="description" id="description" rows="5" cols="93" style="resize: none;"></textarea>
				<br>
				<br>				
			</div>
			<div id="tabs-2">
				<br>
				Variantes :&nbsp;  <select name="variantes">
				<?php
				// boucle d'affichage de toutes les variantes
				foreach($this->variantes as $variante) {
				?>
				<option value="<?php echo $variante->id ?>"><?php echo $variante->nom ?></option>			
				<?php
				}
				?>
				</select>
				<br>
				<br>
				Buy in :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input alt="Montant d'entrée du tournoi" class="numbersOnly" name="buyIn" size="15">
				<br>
				<br>
				Jetons :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input name="tapisDepart" class="numbersOnly" size="15">
				<br>
				<br>
				Recave :&nbsp;&nbsp;&nbsp;&nbsp;  <select name="recave"  id="recave" onchange="javascript:changeRecave()">
							  <option selected value="0">Non</option>
							  <option value="1">Oui</option>
							</select>

				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Montant recave :&nbsp; <input name="montantRecave" id="montantRecave" class="numbersOnly" size="15" disabled='true'>

				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Jetons recave :&nbsp; <input name="jetonRecave" id="jetonRecave" size="15" class="numbersOnly" disabled='true'>
				<br>
				<br>
				Add on :&nbsp;&nbsp;&nbsp;&nbsp;  <select name='addOn' id='addOn' onchange="javascript:changeAddOn()">
							  <option selected value="0">Non</option>
							  <option value="1">Oui</option>
							</select>
							
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Montant add on :&nbsp; <input name="montantAddon" id="montantAddon" class="numbersOnly" size="15" disabled='true'>
				
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Jetons add on :&nbsp; <input name="jetonAddon" id="jetonAddon" class="numbersOnly" size="15" disabled='true'>
				<br>
				<br>
				<br>
			</div>
			<div id="tabs-3">
				<br>
				Structure :&nbsp;  <select name="structures">
				<?php
				// boucle d'affichage de toutes les structures publiques et du joueur connecté
				foreach($this->structures as $structure) {
				?>
				<option value="<?php echo $structure->id ?>"><?php echo $structure->description ?></option>			
				<?php
				}
				?>
				</select>
				<br>
				<div class="component_simplethu">
					<h1 class="componentheading">Liste des tournois</h1>
					<table id="grid_id"></table>
					<!-- <div id="pager1"></div> -->
				</div>
			</div>	
			<div id="tabs-4">
				<select name="participants[]" class="multiselect" id="participants" multiple="multiple" >
				<?php
				// boucle d'affichage de tous les users
				foreach($this->users as $user) {
				?>
				<option value="<?php echo $user->id ?>"><?php echo $user->username ?></option>			
				<?php
				}
				?>
				</select>
				<br>
			</div>
		</div>
		<br>
		<br>
		<br>
		<input name="submit" id="btn_creer" value="Cr&eacute;er" type="submit">
	</form>
</div>
